package com.itheima.testjian;

import org.w3c.dom.ls.LSOutput;

import java.sql.SQLOutput;
import java.util.Scanner;

public class ScannerLiZi {
    public static void main(String[] args) {

        Student s = new Student();
        Scanner sc = new Scanner(System.in);

        System.out.println("请输入您的姓名:");
        String name = sc.next();
        s.setName(name);


        while (true) {
            System.out.println("请输入您的年龄：");
            String ageStr = sc.nextLine();
            try {
                int age = Integer.parseInt(ageStr);
                s.setAge(age);
                break;
            } catch (NumberFormatException e) {
                System.out.println("请输入一个整数：");
                continue;
            } catch (RuntimeException e) {
                System.out.println("请输入一个符合范围的年龄：");
                continue;
            }

        }
        System.out.println(s);
    }




}
